﻿@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_Form.cshtml";
}
<script>
    var keyValue = $.request("keyValue");
    $(function () {
        if (!!keyValue) {
            //$.ajax({
            //    url: "/OrderFlowManage/TakelookAllot/GetFormJson",
            //    data: { keyValue: keyValue },
            //    dataType: "json",
            //    async: false,
            //    success: function (data) {
            //        $("#form1").formSerialize(data);
            //    }
            //});
        }

        $.ajax({
            url: "/OrderFlowManage/TakelookAllot/GetActiveOrderInfo",
            data: { },
            dataType: "json",
            async: false,
            success: function (data) {
                var themes = [],
                    users = [];
                console.log("GetActiveOrderActivityThemes:  ")
                console.log(data);

                if (data) {
                    for (var i = 0; i < data.Themes.length; i++) {
                        var item = data.Themes[i];
                        themes.push('<option value="' + item.F_OrderId + '|' + item.F_No + '|' + item.F_SiteId + '|' + item.F_SpaceId + '|' + '">' + item.F_ActivityTheme + '-' + item.F_SiteName + '-' + item.F_SpaceName + '</option>')
                    }

                    for (var i = 0; i < data.Users.length; i++) {
                        var item = data.Users[i];
                        users.push('<option value="' + item.Value + '">' + item.Text + '</option>')
                    }
                    $("#txt_depts").html('<option value="' + data.Dept.Value + '">' + data.Dept.Text + '</option>').bindSelect();
                    $("#txt_themes").html(themes.join('')).bindSelect();
                    $("#txt_users").html(users.join('')).bindSelect();
                }
            }
        });
    });
    function submitForm() {
        if (!$('#form1').formValid()) {
            return false;
        }
        var orderInfoStr = $("#txt_themes").val();
        if (orderInfoStr) {
            var orderInfo = orderInfoStr.split('|');

            $.submitForm({
                url: "/OrderFlowManage/TakelookAllot/SubmitForm?keyValue=" + keyValue,
                param: {
                    F_OrderId: orderInfo[0],
                    F_No: orderInfo[1],
                    F_SiteId: orderInfo[2],
                    F_SpaceId: orderInfo[3],
                    F_TakelookUserId: $("#txt_users").val()
                },
                success: function () {
                    $.currentWindow().$("#gridList").trigger("reloadGrid");
                }
            });
        } else {
            $.modalAlert("没有添加带看的需求", "success");
        }
       
    }
</script>

<form id="form1">
    <div style="padding-top: 20px; margin-right: 20px;">
        <table class="form">
            <tr>
                <th class="formTitle">活动主题及场地空间</th>
                <td class="formValue">
                    <select id="txt_themes" name="txt_themes" class="form-control txt_themes"></select>
                </td>
            </tr>
            <tr>
                <th class="formTitle">部门</th>
                <td class="formValue">
                    <select id="txt_depts" name="txt_depts" class="form-control txt_depts"></select>
                </td>
            </tr>
            <tr>
                <th class="formTitle">带看人员</th>
                <td class="formValue">
                    <select id="txt_users" name="txt_users" class="form-control txt_users"></select>
                </td>
            </tr>
        </table>
    </div>
</form>


